// 找到连续大于等于k的最小连续值的下标
// k为最后一项
let arr = [2, 3, 5, 1, 2, 3, 9, 9]

function getIndex(arr) {
    let k = arr.pop()
    let map = new Map()
    for (let i = 0; i < arr.length; i++) {
        let sum = arr[i]
        
        let tempArr = []
        tempArr.push(i)
        if(sum >= k) {
            map.set(1, tempArr)
        }
        for (let j = i + 1; j < arr.length; j++) {

            if (sum >= k) {
                map.set(tempArr.length, tempArr)
                break
            }
            sum += arr[j]
            tempArr.push(j)
        }
    }
    let keys = map.keys().length
    if (keys == 0) {
        return arr
    }
    else {
        let keys = map.keys()
        let min = Math.min(...keys)
        return map.get(min)
    }
}

console.log(getIndex(arr));